package com.sky.controller.user;

import com.sky.dto.MeetingRoomQueryDTO;
import com.sky.dto.ReservationDTO;
import com.sky.entity.MeetingRoom;
import com.sky.mapper.MeetingRoomMapper;
import com.sky.result.Result;
import com.sky.service.MeetingRoomService;
import com.sky.service.ReservationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/user/reservations")
@Api(tags="预定接口")
public class ReservationController {

    @Autowired
    private ReservationService reservationService;

    @Autowired
    private MeetingRoomService meetingRoomService;

    /**
     * 预定会议室
     * @param reservationDTO
     * @return
     */
    @ApiOperation(value="预定会议室")
    @PutMapping
    public Result<String> createReservation(@RequestBody ReservationDTO reservationDTO) {
        //能传进来的都是符合条件的，时间肯定正确——但是还是筛选一下吧
        String result=reservationService.bookRoom(reservationDTO);
        if(!result.equals("预定成功")){
            return Result.error("对不起，您预定的会议室时间有冲突");
        }
        return Result.success(result);
    }




}